package top.healthylife.gateway.platform.br.api.api.basicdata;


import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import top.healthylife.gateway.core.service.ParentFace;
import top.healthylife.gateway.dto.annotation.ApiServiceExplain;
import top.healthylife.gateway.platform.br.api.utils.GetmeltingTokenUtils;
import top.healthylife.gateway.platform.br.dto.basicdata.verificationlending.req.BrReqVerificationLendingDto;
import top.healthylife.gateway.platform.br.dto.basicdata.verificationlending.res.BrResVerificationLendingDto;

/**
 * @author cl
 * @version 1.0
 * @date 2020/4/23 10:39
 */
@Slf4j
@Service
@ApiServiceExplain( docUrl="https://account-self.100credit.com/", price = 20,apiName = "借贷意向验证", info = "用户近7/15天、1/3/6/12个月在百融的虚拟信贷联盟(银行、非银、非银细分类型)中的多次信贷申请情况")
public class VerificationLendingApi implements ParentFace<BrReqVerificationLendingDto, BrResVerificationLendingDto> {
    /**
     * 接口唯一标识
     */
    static final String APIIDENTIFICATION = "ApplyLoanStr";

    /**
     * 接口版本号
     */
    static final String VESION = "2.0";

    @Override
    public BrResVerificationLendingDto execute(BrReqVerificationLendingDto brDemoApi){
        //访问百融获取数据
        String apiData = GetmeltingTokenUtils.getApiData(APIIDENTIFICATION, VESION
                , BeanUtil.beanToMap(brDemoApi), GetmeltingTokenUtils.systemConfigInfo(brDemoApi));
        return JSON.parseObject(apiData, BrResVerificationLendingDto.class);
    }
}
